﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;

using BizElements.Core.ProviderComponents;

namespace BizElements.Core
{
    /// <summary>A collection of entities of the same type, ie. which are stored in the same database table.</summary>
    public interface IEntityCollection : IList, ICollection, IEnumerable
    {
        #region Properties and indexers.

        /// <summary>Gets or sets entity at the specified zero-based index.</summary>
        /// <param name="index">The zero-based index of the entity to get or set. </param>
        /// <returns>The entity at the specified index.</returns>
        new IEntity this[int index] { get; set; }

        /// <summary>Gets <see cref="IDbTable"/> object for table/view that stores entities from this collection.</summary>
        IDbTable IDbTable { get; }

        #endregion

        #region Methods.

        /// <summary>
		/// Adds an entity to the end of the collection.
		/// </summary>
		/// <param name="entity">The entity to be added to the end of the EntityCollection. 
		/// Nulls are not allowed, otherwise a NoNullAllowedException is generated.
		/// Entity must be an instance of a class compatible with <see cref="IDbTable"/>.</param>
		/// <param name="validateEntityType">Indicates whether the type of entity is validated to
		/// determine if it is an instance of a class compatible with <see cref="IDbTable"/>.
		/// Set to <b>false</b> only when absoulutely sure that the entity is compatibile.
		/// Setting this parameter to <b>false</b> may increase performance.</param>
        void Add(IEntity entity, bool validateEntityType);

        #endregion        
    }
}